
 <!-- START DATATABLE 2 -->
<div class="table-bordered">
	<table id="<?php echo $config['table_name'] ?>" class="table table-striped table-bordered table-hover"  cellspacing="0" width="100%">
		<thead>
			<tr>
			<?php foreach($header as $head_value) {
				$attr = "";
				foreach((array)@$head_value['attr'] as $hk => $hv)
					$attr .= "$hk=\"$hv\" ";
				if(isset($head_value['type'])) {
					echo "<th type=\"{$head_value['type']}\"><input type=\"{$head_value['type']}\"  {$attr} /></th>";
				} else echo "<th {$attr}>{$head_value['name']}</th>";
			} ?>
			</tr>
		</thead>

		<tfoot>
			<tr>
			<?php foreach($header as $head_value) {
				$attr = "";
				foreach((array)@$head_value['attr'] as $hk => $hv)
					$attr .= "$hk=\"$hv\" ";
				if(isset($head_value['type'])) {
					echo "<th type=\"{$head_value['type']}\"><input type=\"{$head_value['type']}\"  {$attr} /></th>";
				} else echo "<th {$attr}>{$head_value['name']}</th>";
			} ?>
			</tr>
		</tfoot>
	</table>
</div>
 <!-- START DATATABLE 2 -->
<script type="text/javascript">
$(document).ready(function() {

	$('#<?php echo $config['table_name'] ?> tfoot th').each( function () {
		var th = $('#<?php echo $config['table_name'] ?> thead th').eq( $(this).index() );
		var type = th.attr('type');
		if(type === undefined) {
			var title = th.text();
			$(this).html( '<input type="text" class="form-control" placeholder="Search '+title+'" style="max-width: 100%;width: 100%;" />' );
		}
    } );
	
    var dttable = $('#<?php echo $config['table_name'] ?>').dataTable( {
		dom: '<"top"fl>rt<"bottom"pi><"clear">',
		processing: true,
        serverSide: true,
        ajax: <?php echo json_encode($config['ajax']); ?>,
        language: {
            url: "//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Vietnamese.json"
        },
		aoColumnDefs: <?php echo json_encode($format_cols); ?>
    } );
	
	var dttable = $('#<?php echo $config['table_name'] ?>').DataTable();
	
	dttable.columns().eq( 0 ).each( function ( colIdx ) {
		var th = $('#<?php echo $config['table_name'] ?> tfoot th').eq( colIdx );
        $( 'input[type=text]', th ).on( 'keyup change', function () {
            dttable
                .column( colIdx )
                .search( this.value )
                .draw();
        } );
    } );
	
	<?php foreach($config['action'] as $conf_k => $conf_v) { ?>
	$(document).on('<?php echo $conf_k ?>', '<?php echo $conf_v["object"]; ?>', function(){
		<?php echo $conf_v['func']."();"; ?>
	});
	<?php } ?>
});
</script>